<?php
class Admin_Model_News extends Zend_Db_Table_Abstract
{
    protected $_name = 'news';
    
    public function getAllData(){
        $modelNewsCat=new Admin_Model_Newscat();
        $cols=$modelNewsCat->info(Zend_Db_Table_Abstract::COLS);                
        foreach($cols as $col){            
            $newsCatCols[]=$col.' as newsCat_'.$col;
        }
        $modelNewsItem=new Admin_Model_Newsitem();
        $cols=$modelNewsItem->info(Zend_Db_Table_Abstract::COLS);                
        foreach($cols as $col){            
            $newsItemCols[]=$col.' as newsItem_'.$col;
        }        
		$query = $this->select()
                        ->setIntegrityCheck(false)
                        ->from(array('n'=>$this->_name),array('n.newsId','n.itemId','n.title','n.shortTitle','n.description','n.content','n.photo','n.thumb','n.display','n.homeDisplay','n.highlight','n.postDate'))
                        ->join(array('i'=>'news_item'),"n.itemId = i.itemId",$newsItemCols)
                        ->join(array('c'=>'news_cat'),"i.catId = c.catId",$newsCatCols);                                           
        return $this->fetchAll($query);
        
    }
    
     public function getWhere($id){
        $se=$this->select();
        $se->where("id=$id");        
        if($kq=$this->fetchRow($se))
            return $kq->toArray();
        else
            return false;  
    }
    
    public function updateCat($data,$id){
        $this->update($data,"id=$id");          
    }
    
    
    
}

